//- Copyright (c) 2016 Lucky Byte, Inc.
extends ../table

block form_items
  .field.thirteen.wide
    .ui.buttons.right.floated
      if page_perms.new
        button#new.ui.left.icon.labeled.green.button(type="button"
          onclick="window.location = '/fee/new'") 新 增
          i.icon.plus
      else
        button#new.ui.green.icon.button.disabled(type="button")
          i.icon.ban(style="margin-top:1px; margin-right:2px;")
          | 新 增
          
      button#new.ui.blue.button(type="button"
        onclick="window.location = '/fee/set'") 手续费设置

block thead
  tr
    th.center.aligned 序号
    th.center.aligned 名 称
    th.center.aligned 借记卡手续费
    th.center.aligned 贷记卡手续费
    th.center.aligned 引用数
    th.center.aligned 备 注

block tbody
  each record, index in records
    tr(class="#{record.root ? 'positive' : ''}")
      - var debit_rules_html = ''
      - var debit_rules = ''
      each rule in record.debit_rules
        - var contents = ''
        if rule.fix
          - debit_rules_html += "<i class='icon yen blue'></i>"
          if rule.amt_max > 0
            - contents += "上限 " + fmtamt(rule.amt_max) + " 元"
          else
            - contents += "无上限"
          - contents += "，收取定额 " + fmtamt(rule.fee) + " 元"
          - debit_rules += contents
          - debit_rules_html += contents
        else
          - debit_rules_html += "<i class='icon pie chart pink'></i>"
          if rule.amt_max > 0
            - contents += "上限 " + fmtamt(rule.amt_max) + " 元"
          else
            - contents += "无上限"
          - contents += "，收取比例 " + rule.fee + "%"
          - contents += "，保底 " + fmtamt(rule.min) + " 元"
          - contents += "，封顶 " + fmtamt(rule.max) + " 元"
          - debit_rules += contents
          - debit_rules_html += contents
        - debit_rules += " ｜ "
        - debit_rules_html += "<br/>"

      - var cedit_rules_html = ''
      - var cedit_rules = ''
      each rule in record.cedit_rules
        - var contents = ''
        if rule.fix
          - cedit_rules_html += "<i class='icon yen blue'></i>"
          if rule.amt_max > 0
            - contents += "上限 " + fmtamt(rule.amt_max) + " 元"
          else
            - contents += "无上限"
          - contents += "，收取定额 " + fmtamt(rule.fee) + " 元"
          - cedit_rules += contents
          - cedit_rules_html += contents
        else
          - cedit_rules_html += "<i class='icon pie chart pink'></i>"
          if rule.amt_max > 0
            - contents += "上限 " + fmtamt(rule.amt_max) + " 元"
          else
            - contents += "无上限"
          - contents += "，收取比例 " + rule.fee + "%"
          - contents += "，保底 " + fmtamt(rule.min) + " 元"
          - contents += "，封顶 " + fmtamt(rule.max) + " 元"
          - cedit_rules += contents
          - cedit_rules_html += contents
        - cedit_rules += " ｜ "
        - cedit_rules_html += "<br/>"

      td.center.aligned.collapsing
        if page_perms.edit || page_perms.disable
          a(href="/fee/edit/#{record.serial}")= record.serial
        else
          = record.serial
      td.center.aligned.collapsing= record.name
      td.collapsing= debit_rules.substring(0, 35)
        i.icon.ellipsis.horizontal.link.blue(
          data-html="#{debit_rules_html}" data-variation="small very wide")
      td.collapsing= cedit_rules.substring(0, 35)
        i.icon.ellipsis.horizontal.link.blue(
          data-html="#{cedit_rules_html}" data-variation="small very wide")

      td.collapsing.center.aligned= record.n_refs
      td= record.notes
